package com.cnsoft.portal.home;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.cnsoft.framework.beans.MyBeanFactoryHelper;
import org.cnsoft.framework.beans.common.RESTResultBean;
import org.cnsoft.framework.beans.user.UserBean;
import org.cnsoft.framework.cache.session.SessionHelper;
import org.cnsoft.framework.support.MyPageControllerSupport;
import org.cnsoft.framework.utils.DateHelper;
import org.cnsoft.framework.utils.EmptyHelper;
import org.cnsoft.persistent.common.ManagerMenu.ManagerMenuDBO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * 超管菜单权限
 * 
 * @author ZmSoft
 * @version 0.1.0 2018/3/1
 * @since 0.1.0 2018/3/1
 */
@Controller
// @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RequestMapping(value = "/pc/1.0/manager")
public class PageManagerHomeController extends MyPageControllerSupport {

	@RequestMapping(value = "/center", method = RequestMethod.GET)
	public ModelAndView doAdminHomeGET(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView model = getModelAndView(request, "/manager/main-center");

		UserBean currentUser = SessionHelper.currentUser();

		// 首页简报
		model.addObject("DDD", DateHelper.currentTimeMillis2());
		model.addObject("loginer", currentUser);

		return model; // 返回result对象给前端
	}

	@RequestMapping(value = "/home.do", method = RequestMethod.POST)
	public ModelAndView doAdminHomeDoPOST(String superPassword) throws Exception {
		ModelAndView model = getModelAndView("/manager/main-menu2");// 带权限的main-menu2,不带权限main-menu

		//无效密码
		if(EmptyHelper.isEmpty(superPassword)) {
			
		}
		UserBean currentUser = SessionHelper.currentUser();

		// 加载菜单数据
		ISManagerHomeService _ManagerHomeService_ = MyBeanFactoryHelper.getBean(ISManagerHomeService.class);
		RESTResultBean<List<ManagerMenuDBO>> result = _ManagerHomeService_.doUserMenu(new ManagerMenuDBO() );

		model.addObject("menu", result.getData());

		model.addObject("DDD", DateHelper.currentTimeMillis2());
		model.addObject("MENU", result.getData());
		model.addObject("token", SessionHelper.currentToken());
		model.addObject("loginer", currentUser);

		return model; // 返回result对象给前端
	}
	
//	@RequestMapping(value = "/home", method = RequestMethod.POST)
//	public ModelAndView doAdminHomePOST(HttpServletRequest request, HttpServletResponse response) throws Exception {
//		ModelAndView model = getModelAndView(request, "/manager/main-menu2");// 带权限的main-menu2,不带权限main-menu
//
//		UserBean currentUser = SessionHelper.currentUser();
//
//		// 加载菜单数据
//		ISManagerHomeService _ManagerHomeService_ = MyBeanFactoryHelper.getBean(ISManagerHomeService.class);
//		RESTResultBean<List<ManagerMenuDBO>> result = _ManagerHomeService_.doUserMenu(null);
//
//		model.addObject("menu", result.getData());
//
//		model.addObject("DDD", DateHelper.currentTimeMillis2());
//		model.addObject("MENU", result.getData());
//		model.addObject("token", SessionHelper.currentToken());
//		model.addObject("loginer", currentUser);
//
//		return model; // 返回result对象给前端
//	}
	
}
